plan9 尝试werc

Table of Contents

什么是werc

摘自官网

Werc is a minimalist web anti-framework built following the Unix and Plan 9 tool philosophy of software design.
Werc 是一个极简主义的 Web 反框架,遵循 Unix 和 Plan 9 工具软件设计哲学。

Werc avoids the pain of managing collections of websites and developing web applications.
Werc 避免了管理网站集合和开发 Web 应用程序的痛苦。

Database free, uses files and directories instead.
没有数据库,而是使用文件和目录。
Written using the rc shell, leveraging the standard Unix/Plan 9 command toolkit.
使用 rc shell 编写,利用标准 Unix/Plan 9 命令工具包。
Minimize tedious work: eg., no need to ever write HTML, use markdown (or any other format) instead.
最大限度地减少繁琐的工作:例如,无需编写 HTML,而是使用 markdown(或任何其他格式)。
Very minimalist yet extensible codebase: highly functional core is 150 lines, with extra functionality in modular apps.
非常简约但可扩展的代码库:功能强大的核心有 150 行,在模块化应用程序中具有额外的功能。

简单来说,werc是一个和web框架类似的东西,不过它遵循极简主义,能用plan9系统自带的shell和文件系统,就不用三方的程序语言和数据库。这只是我用来体验plan9风格程序的实验。

werc的官网自己就是用werc搭建的,可以看到风格也是极简的黑白风。

plan9 尝试werc.org_20240618_170328_F0qNdK.png

实践使用

我写了一个简单的werc-quickstart demo来演示使用它。

  1. 首先下载werc项目代码和9base项目,9base包含了许多plan9相关的命令工具。

    hg clone https://code.9front.org/hg/werc/
    apt install 9base
    
  2. 然后进入werc将几个demo site拷贝成自己的地址

    cd ./werc/sites
    cp -r werc.cat-v.org localhost
    
  3. 再修改werc bin中werc.rc脚本中的shebang让它指向安装9base后的rc命令。

    file: ./werc/bin/werc.rc
    #!/usr/bin/plan9/bin/rc
    file: ./werc/bin/contrib/md2html.awk
    #!/usr/bin/awk
    
  4. 再用我werc-quikstart项目中的server启动一个cgi server指向werc目录。

    go run server.go
    #go run server.go --root "./werc" --sites "sites" --addr ":8000"
    
  5. 然后你就可以在 http://locahost:8000 的地址中访问到werc构建的网站了。
    因为werc的网页非常精简,你也可以在终端中通过终端浏览器lynx来访问它

    lynx http://localhost:8000